library(tidyverse)
library(fixest)
library(showtext)
library(vtable)
library(writexl)
library(haven)
library(gridExtra)

setwd('D:\\WorkingPaper-Series\\Township_Light\\Replication_Files\\workdata')

#################################
########## Figure 5 #############
#################################

by_cohort_est <- read_delim('by_cohort_est.csv')
by_cohort_est <- by_cohort_est %>% mutate(upper_ci = coef + 1.96*std_err, lower_ci = coef - 1.96*std_err) %>% 
  mutate(sign = as.factor(sign))
  

by_cohort_est %>% ggplot(aes(cohort,coef,color = sign),show.legend = FALSE)+
  geom_hline(yintercept = 0,color = 'grey30', lwd = 0.7, lty = 4)+
  geom_vline(xintercept = 2015.8, color = 'grey50', lwd = 0.5, lty = 4)+
  geom_point(aes(shape = sign),show.legend = FALSE)+
  geom_errorbar(aes(ymin = lower_ci, ymax = upper_ci), width=0, lwd = .3,show.legend = FALSE)+
  theme_bw()+
  theme(text = element_text(family = 'serif',size = 8),
        axis.text =  element_text(family = 'serif',size = 8))+
  labs(y = '', x = 'Treatment Timing') +
  scale_x_continuous(breaks = c(seq(2014,2020,2)), labels = c(seq(2014,2020,2)))+
  scale_color_manual(values = c('postive' = 'grey50', 'negative' = 'black'))